/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package enterprise.ent;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author JAVIER
 */
@Entity
@Table(name = "codigospostales")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Codigospostales.findAll", query = "SELECT c FROM Codigospostales c"),
    @NamedQuery(name = "Codigospostales.findByIdCodigopostal", query = "SELECT c FROM Codigospostales c WHERE c.idCodigopostal = :idCodigopostal"),
    @NamedQuery(name = "Codigospostales.findByPais", query = "SELECT c FROM Codigospostales c WHERE c.pais = :pais"),
    @NamedQuery(name = "Codigospostales.findByProvincia", query = "SELECT c FROM Codigospostales c WHERE c.provincia = :provincia"),
    @NamedQuery(name = "Codigospostales.findByPoblacion", query = "SELECT c FROM Codigospostales c WHERE c.poblacion = :poblacion"),
    @NamedQuery(name = "Codigospostales.findProvincias", query = "SELECT distinct c.provincia FROM Codigospostales c WHERE c.pais = :pais order by c.provincia"),
    @NamedQuery(name = "Codigospostales.findPoblaciones", query = "SELECT distinct c.poblacion FROM Codigospostales c WHERE c.pais = :pais and c.provincia = :provincia order by c.poblacion"),
    @NamedQuery(name = "Codigospostales.findCodigosPostales", query = "SELECT c.codPostal FROM Codigospostales c WHERE c.pais = :pais and c.provincia = :provincia and c.poblacion = :poblacion order by c.codPostal"),
    @NamedQuery(name = "Codigospostales.findByCodPostal", query = "SELECT c FROM Codigospostales c WHERE c.codPostal = :codPostal")})
public class Codigospostales implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_codigopostal")
    private Integer idCodigopostal;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 3)
    @Column(name = "pais")
    private String pais;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 48)
    @Column(name = "provincia")
    private String provincia;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 64)
    @Column(name = "poblacion")
    private String poblacion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 5)
    @Column(name = "cod_postal")
    private String codPostal;

    public Codigospostales() {
    }

    public Codigospostales(Integer idCodigopostal) {
        this.idCodigopostal = idCodigopostal;
    }

    public Codigospostales(Integer idCodigopostal, String pais, String provincia, String poblacion, String codPostal) {
        this.idCodigopostal = idCodigopostal;
        this.pais = pais;
        this.provincia = provincia;
        this.poblacion = poblacion;
        this.codPostal = codPostal;
    }

    public Integer getIdCodigopostal() {
        return idCodigopostal;
    }

    public void setIdCodigopostal(Integer idCodigopostal) {
        this.idCodigopostal = idCodigopostal;
    }

    public String getPais() {
        return pais;
    }

    public void setPais(String pais) {
        this.pais = pais;
    }

    public String getProvincia() {
        return provincia;
    }

    public void setProvincia(String provincia) {
        this.provincia = provincia;
    }

    public String getPoblacion() {
        return poblacion;
    }

    public void setPoblacion(String poblacion) {
        this.poblacion = poblacion;
    }

    public String getCodPostal() {
        return codPostal;
    }

    public void setCodPostal(String codPostal) {
        this.codPostal = codPostal;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCodigopostal != null ? idCodigopostal.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Codigospostales)) {
            return false;
        }
        Codigospostales other = (Codigospostales) object;
        if ((this.idCodigopostal == null && other.idCodigopostal != null) || (this.idCodigopostal != null && !this.idCodigopostal.equals(other.idCodigopostal))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "enterprise.ent.Codigospostales[ idCodigopostal=" + idCodigopostal + " ]";
    }
    
}
